package com.hstyle.bms.config.server;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.hstyle.bms.dto.ShopTradeWhTransDTO;
import com.hstyle.framework.mapper.BeanMapper;
import com.hstyle.framework.rs.server.WsConstants;
import com.wansin.bms.config.shopTradeWh.service.facade.ShopTradeWhFACADE;
import com.wansin.common.util.StringUtil;
import com.wansin.common.util.limit.LimitInfo;
import com.wansin.model.dto.bms.config.shopTradeWh.ShopTradeWhDTO;

@Path("/ShopTrade")
public class ShopTradeWhService {

	ShopTradeWhFACADE shopTradeWhFacade;

	@GET
	@Path("/getShopTrade")
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML + WsConstants.CHARSET })
	public ShopTradeWhTransDTO getShopTradeWhByShopOidAndTradeType(@QueryParam("shopOid") String shopOid ,@QueryParam("tradetype") String tradetype){
		
		if(StringUtil.isNotBlank(shopOid) && StringUtil.isNotBlank(tradetype)){
			
			ShopTradeWhDTO dto = this.shopTradeWhFacade.getShopTradeWhByShopOidAndTradeType(shopOid, tradetype);
			if(dto!=null){
				ShopTradeWhTransDTO transDto = BeanMapper.map(dto,ShopTradeWhTransDTO.class);			
				return transDto;
			}		
		}
		return null;
	}
	
	@GET
	@Path("/getAllShopTrade")
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML + WsConstants.CHARSET })	
    public List<ShopTradeWhTransDTO> getAllShopTradeList(){
		LimitInfo limit = new LimitInfo("Z",-1);
		try{
			
			List<ShopTradeWhTransDTO> shopTradeList =  this.shopTradeWhFacade.list(limit);
			return shopTradeList;
		}
		catch(Exception e){
			e.printStackTrace();
		}

		return null;
	}

	public ShopTradeWhFACADE getShopTradeWhFacade() {
		return shopTradeWhFacade;
	}

	public void setShopTradeWhFacade(ShopTradeWhFACADE shopTradeWhFacade) {
		this.shopTradeWhFacade = shopTradeWhFacade;
	}
	
}
